package sopia.ctrl;

import java.util.ArrayList;


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ItemExpenseCustomizeAdapter extends ArrayAdapter<ItemExpense> {

	public ArrayList<ItemExpense> array;
    public int resource;
    private Context context;
	public ItemExpenseCustomizeAdapter(Context context, int textViewResourceId,
			ArrayList<ItemExpense> objects) {
		super(context, textViewResourceId, objects);
		this.array = objects;
		this.resource = textViewResourceId;
		this.context = context;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
    	View itemView = convertView;
    	if (itemView == null) {
    		itemView = new ItemExpenseCustomizeView(getContext());
    	}
    	final ItemExpense item = array.get(position);
  
    	if (item != null) {
    		TextView account_detail = ((ItemExpenseCustomizeView) itemView).account_detail;
    		TextView item_detail = ((ItemExpenseCustomizeView) itemView).item_detail;
    		TextView amount_detail = ((ItemExpenseCustomizeView) itemView).amount_detail;
    		TextView type_detail = ((ItemExpenseCustomizeView) itemView).type_detail;
    		TextView date_detail = ((ItemExpenseCustomizeView) itemView).date_detail;
    		TextView comment_detail = ((ItemExpenseCustomizeView) itemView).comment_detail;
    		
    		account_detail.setText(item.getAccount());
    		item_detail.setText(item.getItem());
    		amount_detail.setText(item.getAmount());
    		type_detail.setText(item.getType());
    		date_detail.setText(item.getDate());
    		comment_detail.setText(item.getComment());
    	}
    	return itemView;
    }

}
